package cn.elegent.tx.core.entity;

import cn.elegent.tx.config.RollBackConfig;

import java.util.List;
/**
 * TransactionEntity
 * @description 事务对象类
 * @author WGL
 * @date 2022/11/7 0:20
*/
public class TransactionEntity{

    /**
     * 服务名
     */
    private String serverName;

    /**
     * 消息体
     */
    private List<Object> args;

    /**
     * 事务id
     */
    private String transactionId;

    /**
     * 总事务名称
     */
    private String mainName;

    /**
     * 子事务名称
     */
    private String childName;

    /**
     * 默认当我们构建这个事务对象的时候提取配置文件中的服务名
     */
    public TransactionEntity() {
        this.serverName = RollBackConfig.getServerName();
    }

    public TransactionEntity(List<Object> args, String transactionId, String mainName, String childName) {
        this.serverName = RollBackConfig.getServerName();
        this.args = args;
        this.transactionId = transactionId;
        this.mainName = mainName;
        this.childName = childName;
    }

    //系统屏蔽serverName字段 不提供get 、 Set方法
    public List<Object> getArgs() {
        return args;
    }

    public void setArgs(List<Object> args) {
        this.args = args;
    }

    public String getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

    public String getMainName() {
        return mainName;
    }

    public void setMainName(String mainName) {
        this.mainName = mainName;
    }

    public String getChildName() {
        return childName;
    }

    public void setChildName(String childName) {
        this.childName = childName;
    }

    @Override
    public String toString() {
        return "TransactionEntity{" +
                "serverName='" + serverName + '\'' +
                ", args='" + args + '\'' +
                ", transactionId='" + transactionId + '\'' +
                ", mainName='" + mainName + '\'' +
                ", childName='" + childName + '\'' +
                '}';
    }
}
